'use strict';
const db = uniCloud.database()
const weight = db.collection('weight_data')
exports.main = async (event, context) => {
	//event为客户端上传的参数
	let pageSize = event.pageSize || 10
	let currentPage = event.currentPage || 1
	const data = await weight.where({
		openid: event.openid
	}).field({
		date: true,
		unit: true,
		weight: true,
		_id: true
	}).skip(pageSize * (currentPage - 1)).limit(pageSize).orderBy("date", 'desc').get()
	//返回数据给客户端
	return {
		code: 200,
		msg: "获取成功",
		data
	}
};